package MetroMessenger;

import java.io.IOException;
import java.util.Formatter;
import java.net.Socket;

public class MessageSender implements Runnable 
{
   private Socket clientSocket; 
   private String messageToSend; 

   public MessageSender( Socket socket,String message ) 
   {
      clientSocket = socket; 
      messageToSend = message;
   } 
   
   public void run() 
   {
      try
      {     
         Formatter output = new Formatter( clientSocket.getOutputStream() );
         output.format( "%s\n", messageToSend );
         output.flush(); 
      } 
      catch ( IOException ioException ) 
      {
         ioException.printStackTrace();
      }
   }
}